﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EQual.MainModule.Documents.Presenters;
using EQual.MainModule.Documents.Views;
using System.ComponentModel;

namespace EQual.MainModule.Documents.Models
{

    public class DocumentsPresentationModel : EQual.Infrastructure.MVPFramework.Models.PresentationModelBase<DataAccesLayer.Document >,IDocumentsPresentationModel 
    {
        IDocumentsController _controller;
        string _headerInfo;

        public string HeaderInfo { get; set; }

        public IDocumentGridView View { get; set; }

        DataAccesLayer.DocumentDataAccesLayer documentData = new DataAccesLayer.DocumentDataAccesLayer();

        protected override void CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
            {
                _controller.RequestDocumentDelete(e.OldItems as System.Collections.IList);
            }
            base.CollectionChanged(sender, e);
        }

        protected override IEnumerable<DataAccesLayer.Document> GetCollection()
        {
            return documentData.GetDocuments();
        }

        DataAccesLayer.Document _activeItem;

        public DataAccesLayer.Document ActiveItem
        {
            get { return _activeItem; }
            set
            {
                _activeItem = value;
                InvokePropertyChanged(new PropertyChangedEventArgs("ActiveItem"));
            }
        }

    }
}
